<%@page language="java" contentType="text/html; charset=gb2312"%>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*" %>
<%@ page import = "java.net.*" %>

<script language="JavaScript">
	var lastPriorityFilter = new Array();
	var lastStateFilter = new Array();
	var lastLoggerFilter = new Array();
	var lastFixerFilter = new Array();
	var lastTagFilter = new Array();
	var reload = false;
<%
	String reload = request.getParameter("reload");
	if(reload != null && reload.length() != 0) {
		out.println("reload = true;");
	}
	String[] priorities = request.getParameterValues("priority");
	for(String priority : priorities) {
		out.println("lastPriorityFilter.push('"+priority+"');");
	}
	String[] states = request.getParameterValues("state");
	for(String state : states) {
		out.println("lastStateFilter.push('"+state+"');");
	}
	String[] loggers = request.getParameterValues("logger");
	for(String logger : loggers) {
		out.println("lastLoggerFilter.push('"+logger+"');");
	}
	String[] fixers = request.getParameterValues("fixer");
	for(String fixer : fixers) {
		out.println("lastFixerFilter.push('"+fixer+"');");
	}
	String[] tags = request.getParameterValues("tag");
	for(String tag : tags) {
		out.println("lastTagFilter.push('"+tag+"');");
	}
%>
</script>

<%
	URL url = new URL("http://problem.corp.platform.com/cgi-bin/problemEnh/query?${bookmark.url?.encodeAsHTML()}&amp;order=-num");
	URLConnection conn = url.openConnection();
	InputStream is = conn.getInputStream();
	byte[] bytes = new byte[1024];
	int count = 0 ;
	StringBuffer sb = new StringBuffer();
	while( true ) {
		count = is.read(bytes);
		if( count == -1 ) {
			break;
		}
		sb.append(new String(bytes, 0, count));
	}
	
	String s = sb.toString();
	s = s.replaceAll("href='detail\\?problem=", "target='_blank' href='http://problem.corp.platform.com/cgi-bin/problemEnh/detail?problem=");
	s = s.replaceAll("http://benoli.lsf.platform.com/cgi-bin/problem/excel", "/myapp/bookmark/openLink/${params.id}");
	s = s.replaceAll("target='_top'", "");
	s = s.replaceAll("<input type=button value=Export onclick=\"submit_export\\(\\)\">", "<div id='divFilter'></div><div id='divChart'></div>");
	
	String jquery = "<script type=\"text/javascript\" src=\"/myapp/js/jquery.js\"></script>";
	String jsProblem = "<script type=\"text/javascript\" src=\"/myapp/bookmark/js/problem.js\"></script>";
	String jsVisualization = "<script type='text/javascript' src='http://www.google.com/jsapi'></script>";
	String jsChart = "<script type=\"text/javascript\" src=\"/myapp/bookmark/js/chart.js\"></script>";
	String styleCss = "<link rel=\"stylesheet\" href=\"/myapp/bookmark/css/style.css\"/>";
	
	String cssMain = "<link rel=\"stylesheet\" href=\"/myapp/css/main.css\" />";
	s = s.replaceAll("</script>", "</script>" + jquery + jsProblem + jsVisualization + jsChart + cssMain + styleCss);
	
	s = s.replaceAll("<table border=1>", "<div class=\"body\"><div class=\"list\"><table border=1>");
	s = s.replaceAll("</table>", "</table></div></div>");

	out.println(s);
%>


